﻿using Intex.Tools;
using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.Data;
using WPFExcelReport.Helpers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Windows;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using INTEX.DataBase;
using System.Linq;

namespace WPFExcelReport
{

    public partial class ITXQVWData : BaseFunction
    {
        public string SQLDB
        {
            get
            {
                return app.SQLDB;
            }
        }
        public ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        public INTEXDBC INTEXDBC
        {
            get
            {
                return app.INTEXDBC;
            }
        }
        DataSet SetDispo = new DataSet();
        Queue<DataSet> JobQueue;
        DataSet Set4ITX = new DataSet();

        public DataSet SetMap;
        public Convert2Intex Convert2Intex;
        public DataSet SetExt = new System.Data.DataSet();
        public DataSet SetJob;
        public SETINTEXDB SetData;

        SETINTEXDB INTEXDB = new INTEX.DataBase.SETINTEXDB();

        Dictionary<string, string> lstABPOS = new Dictionary<string, string>();
        public ITXQVWData()
        {
            Convert2Intex = new Convert2Intex();
            Helpers.Helper.GetDate(ref date, ref year, ref month, ref day);
        }
        public ITXQVWData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
            Convert2Intex = new Convert2Intex();
            JobQueue = new Queue<DataSet>();
            Helpers.Helper.GetDate(ref date, ref year, ref month, ref day);
        }

        public DataSet LoadEnv()
        {
            DataSet SResult = new DataSet();
            DataSet SReturn = new DataSet();
            Helper.GetDate(ref date, ref year, ref month, ref day);
            SetMap = new DataSet();
            DataSet STemp = new System.Data.DataSet();

            return SReturn;
        }
        public void Refresh()
        { 
            DataRow dwData = INTEXDB.QVW_VKPOS.NewRow();
            dwData["MANDANT"] = "00";
            #region=====SD===========
            INTEXDBC.DeleteQVW_SD0231(dwData, 1);
            INTEXDBC.InsertQVW_SD0231(dwData, 1);
            INTEXDBC.DeleteQVW_LIEFDAT(dwData, 1);
            INTEXDBC.InsertQVW_LIEFDAT(dwData, 1);

            INTEXDBC.DeleteQVW_KDSTAMM(dwData, 1);
            INTEXDBC.InsertQVW_KDSTAMM(dwData, 1);

            INTEXDBC.DeleteQVW_GSDAT(dwData, 1);
            INTEXDBC.InsertQVW_GSDAT(dwData, 1);

            INTEXDBC.DeleteQVW_FWASTAMM(dwData, 1);
            INTEXDBC.InsertQVW_FWASTAMM(dwData, 1);

            INTEXDBC.DeleteQVW_GWASTAMM(dwData, 1);
            INTEXDBC.InsertQVW_GWASTAMM(dwData, 1);

            INTEXDBC.DeleteQVW_BHSATZ(dwData, 1);
            INTEXDBC.InsertQVW_BHSATZ(dwData, 1);

            INTEXDBC.DeleteQVW_FSSTAMM(dwData, 1);
            INTEXDBC.InsertQVW_FSSTAMM(dwData, 1);

            INTEXDBC.DeleteQVW_MSSTAMM(dwData, 1);
            INTEXDBC.InsertQVW_MSSTAMM(dwData, 1);

            INTEXDBC.DeleteQVW_VAART(dwData, 1);
            INTEXDBC.InsertQVW_VAART(dwData, 1);

            INTEXDBC.DeleteQVW_VAFARBEN(dwData, 1);
            INTEXDBC.InsertQVW_VAFARBEN(dwData, 1);

            INTEXDBC.UpdateQVW_VAFARBEN(dwData, 1);
            INTEXDBC.UpdateQVW_VAFARBEN(dwData, 2);
            INTEXDBC.UpdateQVW_VAFARBEN(dwData, 3);



            #endregion

            #region=====STOCK===========
            INTEXDBC.DeleteQVW_WBBST(dwData, 2);
            INTEXDBC.InsertQVW_WBBST(dwData, 1);

            INTEXDBC.UpdateQVW_WBBST(dwData, 1);
            INTEXDBC.UpdateQVW_WBBST(dwData, 2);
            INTEXDBC.UpdateQVW_WBBST(dwData, 3);
            INTEXDBC.UpdateQVW_WBBST(dwData, 4);

            INTEXDBC.DeleteQVW_BABST(dwData, 1);
            INTEXDBC.InsertQVW_BABST(dwData, 1);

            INTEXDBC.UpdateQVW_BABST(dwData, 1);
            INTEXDBC.UpdateQVW_BABST(dwData, 2);
            INTEXDBC.UpdateQVW_BABST(dwData, 3);
            INTEXDBC.UpdateQVW_BABST(dwData, 4);


            INTEXDBC.DeleteQVW_GLLG(dwData, 2);
            INTEXDBC.InsertQVW_GLLG(dwData, 1);

            INTEXDBC.UpdateQVW_GLLG(dwData, 1);
            INTEXDBC.UpdateQVW_GLLG(dwData, 2);
            INTEXDBC.UpdateQVW_GLLG(dwData, 3);
            INTEXDBC.UpdateQVW_GLLG(dwData, 4);


            INTEXDBC.DeleteQVW_MBST(dwData, 1);
            INTEXDBC.InsertQVW_MBST(dwData, 1);

            INTEXDBC.UpdateQVW_MBST(dwData, 1);
            INTEXDBC.UpdateQVW_MBST(dwData, 2);
            INTEXDBC.UpdateQVW_MBST(dwData, 3);
            INTEXDBC.UpdateQVW_MBST(dwData, 4);

            INTEXDBC.DeleteQVW_FBST(dwData, 1);
            INTEXDBC.InsertQVW_FBST(dwData, 1);

            INTEXDBC.UpdateQVW_FBST(dwData, 1);
            INTEXDBC.UpdateQVW_FBST(dwData, 2);
            INTEXDBC.UpdateQVW_FBST(dwData, 3);
            INTEXDBC.UpdateQVW_FBST(dwData, 4);
            #endregion

            #region=====VK===========
            INTEXDBC.DeleteQVW_VKPOS(dwData, 1);
            INTEXDBC.InsertQVW_VKPOS(dwData, 1);
            #endregion

            #region=====EK===========
            INTEXDBC.DeleteQVW_EKPOS(dwData, 1);
            INTEXDBC.InsertQVW_EKPOS(dwData, 1);
            #endregion

            #region=====WS===========
            #endregion

            #region=====QC===========
            INTEXDBC.DeleteQVW_QOSTEP(dwData, 1);
            INTEXDBC.InsertQVW_QOSTEP(dwData, 1);

            INTEXDBC.DeleteQVW_QORDER(dwData, 1);
            INTEXDBC.InsertQVW_QORDER(dwData, 1);

            INTEXDBC.DeleteQVW_QPMERKM(dwData, 1);
            INTEXDBC.InsertQVW_QPMERKM(dwData, 1);
            #endregion

            #region=====AB===========
            INTEXDBC.DeleteQVW_GAAUF(dwData, 1);
            INTEXDBC.InsertQVW_GAAUF(dwData, 1);

            INTEXDBC.DeleteQVW_MCOST(dwData, 1);
            INTEXDBC.InsertQVW_MCOST(dwData, 1);
            INTEXDBC.InsertQVW_MCOST(dwData, 2);
            INTEXDBC.InsertQVW_MCOST(dwData, 3);
            INTEXDBC.InsertQVW_MCOST(dwData, 4);

            INTEXDBC.DeleteQVW_KSLEIST(dwData, 1);
            INTEXDBC.InsertQVW_KSLEIST(dwData, 1);

            INTEXDBC.DeleteQVW_ABPOS(dwData, 1);
            INTEXDBC.InsertQVW_ABPOS(dwData, 1);

            INTEXDBC.DeleteQVW_ABFOLGE(dwData, 1);
            INTEXDBC.InsertQVW_ABFOLGE(dwData, 1);
            INTEXDBC.UpdateQVW_ABFOLGE(dwData, 1);
            INTEXDBC.UpdateQVW_ABFOLGE(dwData, 2);
            INTEXDBC.UpdateQVW_ABFOLGE(dwData, 3);
            INTEXDBC.UpdateQVW_ABFOLGE(dwData, 4);

            INTEXDBC.UpdateQVW_ABPOS(dwData, 1);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 2);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 3);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 4);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 5);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 6);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 7);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 8);
            INTEXDBC.UpdateQVW_ABPOS(dwData, 9);
            #endregion
        }
        public DataSet LoadData(DataRow dwInput)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataSet STemp = new System.Data.DataSet();

            string KRS = "";
            string LFD = "";
            string POS = "";
            DataRow dwData;
            try
            {
                dwData = INTEXDB.QVW_VKPOS.NewRow();
                dwData["MANDANT"] = "00";

                #region======VK========
                SResult = INTEXDBC.QueryQVW_VKPOS(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["VART"] = Convert8859P1ToGB2312(row["VART"].ToString());
                    row["VFARBE"] = Convert8859P1ToGB2312(row["VFARBE"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_VKPOS ", StatusEventType.StopProgress);
                #endregion

                #region======SD========
                SResult = INTEXDBC.QueryQVW_SD0231(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["KOP"] = Convert8859P1ToGB2312(row["KOP"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_SD0231 ", StatusEventType.StopProgress);
                SResult = INTEXDBC.QueryQVW_LIEFDAT(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["LSLIEFNA"] = Convert8859P1ToGB2312(row["LSLIEFNA"].ToString());
                    row["LSNAME1"] = Convert8859P1ToGB2312(row["LSNAME1"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_LIEFDAT ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_VAART(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["VARTBEZ"] = Convert8859P1ToGB2312(row["VARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);

                EventDispatcher.Instance.RaiseStatus("QueryQVW_VAART ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_VAFARBEN(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["VFBEZ"] = Convert8859P1ToGB2312(row["VFBEZ"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                    row["PDESS"] = Convert8859P1ToGB2312(row["PDESS"].ToString());
                    row["PFINISH"] = Convert8859P1ToGB2312(row["PFINISH"].ToString());
                    row["PSIZE"] = Convert8859P1ToGB2312(row["PSIZE"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_VAFARBEN ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_GSDAT(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                    row["GSHANDLNR"] = Convert8859P1ToGB2312(row["GSHANDLNR"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_GSDAT ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_KDSTAMM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["KDSNAME"] = Convert8859P1ToGB2312(row["KDSNAME"].ToString());
                    row["KDNAME"] = Convert8859P1ToGB2312(row["KDNAME"].ToString());
                    row["KDLAND"] = Convert8859P1ToGB2312(row["KDLAND"].ToString());
                    row["KDORT"] = Convert8859P1ToGB2312(row["KDORT"].ToString());
                }

                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_KDSTAMM ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_FWASTAMM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_FWASTAMM ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_GWASTAMM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryQVW_BHSATZ(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_BHSATZ ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_FSSTAMM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryQVW_MSSTAMM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PARTBEZ"] = Convert8859P1ToGB2312(row["PARTBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_MSSTAMM ", StatusEventType.StopProgress);

                #endregion

                #region======STOCK========
                SResult = INTEXDBC.QueryQVW_GAAUF(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                }
                SReturn.Merge(SResult);

                SResult = INTEXDBC.QueryQVW_ZUTEI(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                }
                SReturn.Merge(SResult);

                SResult = INTEXDBC.QueryQVW_BABST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_BABST ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_GLLG(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_GLLG ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_FBST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_FBST ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_MBST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_MBST ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_WBBST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["KOPEBEZ"] = Convert8859P1ToGB2312(row["KOPEBEZ"].ToString());
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                    row["PDESS"] = Convert8859P1ToGB2312(row["PDESS"].ToString());
                    row["PDCWY"] = Convert8859P1ToGB2312(row["PDCWY"].ToString());
                    row["PFINISH"] = Convert8859P1ToGB2312(row["PFINISH"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_WBBST ", StatusEventType.StopProgress);

                #endregion

                #region======EK========
                SResult = INTEXDBC.QueryQVW_EKPOS(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                    row["PDESS"] = Convert8859P1ToGB2312(row["PDESS"].ToString());
                    row["PFINISH"] = Convert8859P1ToGB2312(row["PFINISH"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_EKPOS ", StatusEventType.StopProgress);
                #endregion

                #region======AB========
                SResult = INTEXDBC.QueryQVW_ABPOS(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                    row["PDESS"] = Convert8859P1ToGB2312(row["PDESS"].ToString());
                    row["PDCWY"] = Convert8859P1ToGB2312(row["PDCWY"].ToString());
                    row["PFINISH"] = Convert8859P1ToGB2312(row["PFINISH"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_ABPOS ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_ABFOLGE(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["KOPEBEZ"] = Convert8859P1ToGB2312(row["KOPEBEZ"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_ABFOLGE ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_KSLEIST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["KOPERATION"] = Convert8859P1ToGB2312(row["KOPERATION"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_KSLEIST ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_MCOST(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["PART"] = Convert8859P1ToGB2312(row["PART"].ToString());
                    row["PCOLOR"] = Convert8859P1ToGB2312(row["PCOLOR"].ToString());
                    row["PDESS"] = Convert8859P1ToGB2312(row["PDESS"].ToString());
                    row["PFINISH"] = Convert8859P1ToGB2312(row["PFINISH"].ToString());
                    row["PSIZE"] = Convert8859P1ToGB2312(row["PSIZE"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_MCOST ", StatusEventType.StopProgress);

                #endregion

                #region====QC========

                SResult = INTEXDBC.QueryQVW_QORDER(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    //row["KOPERATION"] = Convert8859P1ToGB2312(row["KOPERATION"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_QORDER ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_QOSTEP(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["MERKM"] = Convert8859P1ToGB2312(row["MERKM"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_SD0231 ", StatusEventType.StopProgress);

                SResult = INTEXDBC.QueryQVW_QPMERKM(dwData, 1);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    row["MERKMBEZ"] = Convert8859P1ToGB2312(row["MERKMBEZ"].ToString());
                    row["MERKM"] = Convert8859P1ToGB2312(row["MERKM"].ToString());
                }
                SReturn.Merge(SResult);
                EventDispatcher.Instance.RaiseStatus("QueryQVW_QPMERKM ", StatusEventType.StopProgress);

                #endregion

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }
        public DataSet LoadRTData(DataRow dwInput)
        {
            DataSet SResult;
            DataSet SReturn = null;
            DataTable tableLocal = null;
            SqlCommand sql;
            //taccstock 
            //select * from taccstock where store like 'qbxa%'
            //采购入库是吧 采购单单据头 TBusPurchase 
            //采购单单据明细TBusPurchase退给外加工厂涉及的出库表结构 
            //采购退 TBusPurRet 采购退货明细TBusPurRetDt
            //select * from TBusPurRet go
            //select * from TBusPurRetDt go
            if (SqlServerDB == null)
            {
                this.SqlServerDB = new SqlConnection(SQLDB);
            } 
            DataRow dwData = INTEXDB.ABPOS.NewRow();
            sql = SqlServerDB.CreateCommand();
            sql.CommandText = "SELECT K.BILLDATE,STORE,CHECKER,TPAYAMOUNT,PICKED,K.FAMOUNT,PAYFAMOUNT,QTY,FOB,DPRICE,PRICE,COST,X.* FROM TBUSRETAIL K JOIN TBUSRETAILDT D ON K.MASTERID=D.MASTERID LEFT JOIN TDEFSKU X ON X.SKU=D.SKU WHERE STORE LIKE 'QBXA%' AND BILLDATE >'2014-01-01' ORDER BY BILLDATE DESC";
            setResult = Connect2Proxy(sql);
            if (setResult.Tables.Count > 0)
            {
                tableLocal = setResult.Tables[0];
                tableLocal.TableName = "DAILYRETAIL";
            }
            setReturn.Merge(setResult);
            return SReturn;
        }
    }
}